import request from '@/utils/http'
import { UserInfo } from '@/types'

const PATH = '/profile'

export async function getProfile() {
	// return request({ url: PATH + '/getprofile', method: 'get' })
	const res = await request({ url: '/user/profile/get', method: 'get' })
	const __ = res.data as UserInfo
	// __.followersCount = __.fanCount
	// __.followingCount = __.followCount
	__.nickName = __.username
	// __.privacy = __.incognitoMode
	__.userName = __.username
	__.userId = __.id
	return res
}

export function setVerifyBasicInfo(data: any) {
	return request({ url: '/user/profile/verifyBasicInfo', method: 'post', data })
}

export function setVerifyIdentity(data: any) {
	return request({ url: '/user/profile/verifyIdentity', method: 'post', data })
}

export function getSessionList(params: any) {
	return request({ url: '/user/profile/sessionList', method: 'get', params })
}

export function logoutSessionById(data: any) {
	return request({ url: `/user/profile/logout/${data.id}`, method: 'post' })
}

export function logoutSessionOther() {
	return request({ url: '/user/profile/logoutOther', method: 'post' })
}

export function updateSignature(data: any) {
	return request({ url: '/user/profile/updateSignature', method: 'post', data })
}

export function setRealname(data: any) {
	return request({ url: PATH + '/setrealname', method: 'post', data })
}

export function setNickname(data: any) {
	return request({ url: PATH + '/setnickname', method: 'post', data })
}

export function setBirthday(data: any) {
	return request({ url: PATH + '/setbirthday', method: 'post', data })
}

export function setEmailOrMobile(data: any) {
	return request({ url: PATH + '/setmailormobile', method: 'post', data })
}

export function modifyEmailOrMobile(data: any) {
	return request({ url: PATH + '/modifymailormobile', method: 'post', data })
}

// export function getAvatarInfo() {
// 	return request({ url: '/asset/avatar/get2upinfo', method: 'get' })
// }

export function updateAvatar(data: any) {
	return request({ url: '/user/profile/updateAvatar', method: 'post', data })
}

export function bindauth(data: any) {
	return request({ url: PATH + '/bindauth', method: 'post', data })
}

export function unbindauth(data: any) {
	return request({ url: PATH + '/unbindauth', method: 'post', data })
}

export function setProfileOdds(data: any) {
	return request({ url: `/user/profile/updateOdds`, method: 'post', data })
}

export function getAboutInfo(params: any) {
	return request({ url: PATH + '/about', method: 'get', params })
}

export const getUserCareer = (params: any) =>
	request({ url: '/portal/career/get', method: 'get', params })
